import './style/index.scss' // 引入scss全局样式
import 'element-plus/dist/index.css'; // 引入element-plus样式
import ElementPlus from 'element-plus'
import Particles from 'particles.vue3'
 
 


import { createApp } from 'vue'
import { createPinia } from 'pinia'
import App from './App.vue'
import {useStore } from '@/store/counter'
import piniaPluginPersist from 'pinia-plugin-persist';
// 引入Vue-Route
import router from '@/router'
const pinia = createPinia()
pinia.use(piniaPluginPersist)

const app = createApp(App)
app.use(pinia)
app.use(router)
app.use(ElementPlus )
app.use(Particles)
app.mount('#app')

// 路由导航守卫
const store = useStore ()
router.beforeEach((to, from, next) => {
    if(to.name === 'login'){
      next()
    }else{
      if(store.token){
          // console.log('token', store.token);   
          next()
      }else{
          console.log('没有token');
          next({name: 'login'})
      }
    }
  })